package org.learn.java.mq.consumer;

import java.util.Properties;

import javax.sound.midi.Receiver;

import org.learn.java.mq.MqContent;
import org.learn.java.mq.listener.MyMessgeListener;

import com.aliyun.openservices.ons.api.Consumer;
import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.aliyun.openservices.ons.api.PropertyValueConst;

public class ConsumerTestBO {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		receive();
	}

	public static void receive() {
		// 配置producer参数
		Properties properties = new Properties();
		properties.put(PropertyKeyConst.ConsumerId, "CID_blue_xdj_1");
		properties.put(PropertyKeyConst.AccessKey, MqContent.MQ_AccessKey );
		properties.put(PropertyKeyConst.SecretKey, "7JbgLiklyNxmkXQkM0iBKWuyqNvnjU");
		 properties.put(PropertyKeyConst.MessageModel,
	                PropertyValueConst.BROADCASTING);
		Consumer consumer = ONSFactory.createConsumer(properties);
		
		MessageListener listener = new MyMessgeListener();
		
		consumer.subscribe("blue_xdj", "test3", listener);
		
		consumer.start();
		System.out.println("consumer2启动成功");
		
	}
}
